package next.TestFunctionality;

import java.io.File;

import next.Functionality.AudioVideoFunctionality;
import next.Functionality.DialogFunctonality.TypeDialog;
import next.Functionality.SmsFunctionality.TypeSMS;
import next.TemplateActivity.R;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;

public class TestMaps extends AudioVideoFunctionality implements  android.view.View.OnClickListener{

	private File sdCard = Environment.getExternalStorageDirectory();
	private RadioGroup rg;
	private RadioButton rb1, rb2, rb3;
	Integer selected=-1;
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.generic_test_layout);
		//--Creating Dialog.
		String [] Botones={"OK","CANCEL"};
		String [] Items={"opcion1","opcion2","opcion3"};
		CreateDialog(TypeDialog.ALERT, R.drawable.icon, "TestingDialog", Botones, Items, null);
		CreateDialog(TypeDialog.PROGRESS, R.drawable.icon, "TestingDialog", Botones, Items, 100);
		//--Assembling widgets		
		Button btn=(Button) findViewById(R.id.test_V_BN1);
		Button btn2=(Button) findViewById(R.id.test_V_BN2);
		Button btn3=(Button) findViewById(R.id.test_V_BN3);
		Button btn4=(Button) findViewById(R.id.test_V_BN4);
		Button btn5=(Button) findViewById(R.id.test_V_BN5);
		
		btn.setOnClickListener(this);
		btn2.setOnClickListener(this);
		btn3.setOnClickListener(this);
		btn4.setOnClickListener(this);
		
		
		 rb1=(RadioButton) findViewById(R.id.test_V_RBN1);
		 rb1.setOnClickListener(myOptionOnClickListener);
		 rb2=(RadioButton) findViewById(R.id.test_V_RBN2);
		 rb2.setOnClickListener(myOptionOnClickListener);
		 rb3=(RadioButton) findViewById(R.id.test_V_RBN3);
		 rb3.setOnClickListener(myOptionOnClickListener);
		
		rg=(RadioGroup) findViewById(R.id.test_V_RG1);
		
		btn5.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				startActivity( new Intent ("next.SupportFunctionality.MapsFunctionality"));
				
			}
		});
			
	}

	@Override
	public void onClick(View v) {
		if (v.getId()==R.id.test_V_BN1){
			
	 if (selected==1){		
		String [] address={"5556"};
		//Remember that application controller need to know who sends the message.!!!!	
		this.CreateSMS(TypeSMS.CUSTOM, address, "app S-3R4", "TestSMS");
		}
		 else if (selected==2)
		 {
			 DownloadFileRSS("http://www.appleinsider.com/appleinsider.rss");
		 }
		 else if (selected==3){
			 DownloadImageURL("http://cornellchinesetennis.files.wordpress.com/2009/06/roger-federer-with-nsix-one-tour.jpg");
		 }
	}else if (v.getId()==R.id.test_V_BN2){ OpenAudio(R.raw.marry_me_by_train);}
	else if (v.getId()==R.id.test_V_BN3){CloseAudio();}
	else if (v.getId()==R.id.test_V_BN4){OpenVideo(sdCard.getAbsolutePath()+"/BM_LazySong.3gp");}
	else
	Toast.makeText(getBaseContext(), "Button does not exist!",Toast.LENGTH_SHORT).show();	
		
	}
	
	  RadioButton.OnClickListener myOptionOnClickListener =
			   new RadioButton.OnClickListener()
			  {

			  @Override
			  public void onClick(View v) {
			     
				  if (rb1.getId()==v.getId()){
					  selected=1;
				  }
				  else if (rb2.getId()==v.getId()){
					  selected=2;
				  }
				  else  if (rb3.getId()==v.getId()){
					  selected=3;
				  }
				  Toast.makeText(getBaseContext(), "ID: "+selected,Toast.LENGTH_SHORT).show();	
			  }};

}

